package com.edu.bean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

import java.util.IdentityHashMap;

/**
 * @Author:zyn
 * @Date:2025/10/28--12:42:50
 */
public class Student implements BeanNameAware, ApplicationContextAware, InitializingBean, DisposableBean {

    private int stuId;

    private String stuName;

    private int age;

    private IdCard idCard;

    public int getStuId() {
        return stuId;
    }

    public void setStuId(int stuId) {
        this.stuId = stuId;
    }

    public String getStuName() {
        return stuName;
    }

    public void setStuName(String stuName) {
        this.stuName = stuName;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public IdCard getIdCard() {
        return idCard;
    }

    public void setIdCard(IdCard idCard) {
        this.idCard = idCard;
    }

    @Override
    public String toString() {
        return "Student{" +
                "stuId=" + stuId +
                ", stuName='" + stuName + '\'' +
                ", age=" + age +
                ", idCard=" + idCard +
                '}';
    }

    public Student() {
    }

    public void myInit(){
        System.out.println("执行了自定义init方法");
        this.age=this.age+1;
    }

    public void myDestroy(){
        System.out.println("执行了自定义销毁方法");
    }
    @Override
    public void setBeanName(String s) {
        System.out.println("执行了BeanNameAware 的方法");
        System.out.println(s);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        System.out.println("执行了applicationContext 的方法");
        System.out.println(applicationContext);
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("执行了接口的初始化方法");
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("执行了接口的销毁方法");
    }
}
